package net.zhuike.novel.app.bean.local;

import net.zhuike.novel.app.bean.SitBean;
import net.zhuike.novel.app.bean.gen.CollBookBeanDao;
import net.zhuike.novel.app.bean.gen.DaoSession;
import net.zhuike.novel.app.bean.gen.SitBeanDao;

/**
 * Created by wq on 17-4-26.
 */

public class SitRepository {
    private static final String TAG = "SitRepository";
    private static final String DISTILLATE_ALL = "normal";
    private static final String DISTILLATE_BOUTIQUES = "distillate";

    private static volatile SitRepository sInstance;
    private DaoSession mSession;
    private SitBeanDao sitBookDao;
    private SitRepository(){
        mSession = DaoDbHelper.getInstance().getSession();
        sitBookDao=mSession.getSitBeanDao();
    }

    public static SitRepository getInstance(){
        if (sInstance == null){
            synchronized (SitRepository.class){
                if (sInstance == null){
                    sInstance = new SitRepository();
                }
            }
        }
        return sInstance;
    }

    /*************************************数据存储*******************************************/

    public void saveSit(SitBean bean){
        sitBookDao.insertOrReplace(bean);
    }

   public SitBean getSit(String bookId){
       SitBean bean = sitBookDao.queryBuilder()
               .where(SitBeanDao.Properties.Id.eq(bookId))
               .unique();
       return bean;
   }




}
